package com.ruoyi.system.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.chart;
import com.ruoyi.system.service.IchartService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 统计Controller
 * 
 * @author ruoyi
 * @date 2021-11-22
 */
@RestController
@RequestMapping("/chart/statistics")
public class chartController extends BaseController
{
    @Autowired
    private IchartService chartService;

    /**
     * 查询统计列表
     */
    @PreAuthorize("@ss.hasPermi('chart:statistics:list')")
    @GetMapping("/list")
    public TableDataInfo list(chart chart)
    {
        startPage();
        List<chart> list = chartService.selectchartList(chart);
        return getDataTable(list);
    }

    /**
     * 导出统计列表
     */
    @PreAuthorize("@ss.hasPermi('chart:statistics:export')")
    @Log(title = "统计", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(chart chart)
    {
        List<chart> list = chartService.selectchartList(chart);
        ExcelUtil<chart> util = new ExcelUtil<chart>(chart.class);
        return util.exportExcel(list, "统计数据");
    }

    /**
     * 获取统计详细信息
     */
    @PreAuthorize("@ss.hasPermi('chart:statistics:query')")
    @GetMapping(value = "/{ybssId}")
    public AjaxResult getInfo(@PathVariable("ybssId") String ybssId)
    {
        return AjaxResult.success(chartService.selectchartByYbssId(ybssId));
    }

    /**
     * 新增统计
     */
    @PreAuthorize("@ss.hasPermi('chart:statistics:add')")
    @Log(title = "统计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody chart chart)
    {
        return toAjax(chartService.insertchart(chart));
    }

    /**
     * 修改统计
     */
    @PreAuthorize("@ss.hasPermi('chart:statistics:edit')")
    @Log(title = "统计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody chart chart)
    {
        return toAjax(chartService.updatechart(chart));
    }

    /**
     * 删除统计
     */
    @PreAuthorize("@ss.hasPermi('chart:statistics:remove')")
    @Log(title = "统计", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ybssIds}")
    public AjaxResult remove(@PathVariable String[] ybssIds)
    {
        return toAjax(chartService.deletechartByYbssIds(ybssIds));
    }
}
